package com.gyc.simple.sysuser.config;

import com.gyc.simple.sysuser.service.SysResourceService;
import org.apache.shiro.web.filter.PathMatchingFilter;
import org.springframework.context.ApplicationContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.util.Map;
@Component
public class SourceAutoSave implements ApplicationRunner,CommandLineRunner {

    @Autowired
    private ApplicationContext applicationContext;
    @Autowired
    private SysResourceService sysResourceService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        GetAuthorityResources getAnnotations = new GetAuthorityResources(applicationContext);
        Map<String,String> stringMap = getAnnotations.getKeyValues();
        if(stringMap!=null&&sysResourceService.SourceInit(stringMap)){
            System.out.println("---------------------更新了权限资源-------------------------------------");
        }else{
            System.out.println("---------------------没有更新权限资源-------------------------------------");

        }


    }

    @Override
    public void run(String... args) throws Exception {
        System.out.println("yes----");
    }
}
